using System.Web.Mvc;
using Cooking.Core.DataInterfaces;
using Cooking.Core.Model;
using Cooking.Web.Code;

namespace Cooking.Web.Controllers
{
    public class TipController : AppController
    {
        private readonly ITipDao _tipDao;

        public TipController(ITipDao tipDao)
        {
            _tipDao = tipDao;
        }

        public string StatusMessage { get { return TempData["StatusMessage"] as string ?? string.Empty; } set { TempData["StatusMessage"] = value; } }

        public ActionResult Create(string name, string description)
        {
            var tip = new Tip {Description = description, Name = name};
            _tipDao.Create(tip);

            StatusMessage = "Created tip: " + name;
            return RedirectToAction("Index");
        }

        public ActionResult List()
        {
            return View("List", _tipDao.GetList());
        }


        public ActionResult ByName(string Name)
        {
            return View("", _tipDao.LoadById(1));
        }

        public ActionResult Index(int tipId)
        {
            return View("View", _tipDao.LoadById(tipId));
        }
    }
}